import os
import sys
import glob


def generate():
    README = []
    for file in glob.glob(__file__.replace("__init__", "[!__]*")):
        with open(file, mode="r") as pattern:
            README.append(
                f"- __[{pattern.readlines(1)[0].replace("# ", "").strip()
                        }]({file.split('/')[-1]})__"
            )
    README.sort(key=lambda item: "Пораждающий" in item)
    with open('README.md', mode="w") as readme:
        readme.write(
            "\n".join(README)
        )


if __name__ == "__main__":
    generate()
